<script setup lang="ts">
import {defineExpose, defineProps, reactive, ref} from "vue";
import {
  AddSecretKey,
} from "../../../../wailsjs/go/view/SecretText";
import {base} from "../../../../wailsjs/go/models.ts";


const props = defineProps({
  onLoadSecretTextList: {
    type: Function,
    required: true
  }
})


const dialogVisible = ref(false)
const addForm = reactive<base.AddSecretKey>({
  title: "",
  remark: "",
  algorithm: "simple",
})

const clickSubBtn = ()=>{
  AddSecretKey(addForm).then(()=>{
    dialogVisible.value = false
    props.onLoadSecretTextList()
  })
}


defineExpose({
  dialogVisible,
  addForm
})
</script>

<template>
  <el-dialog v-model="dialogVisible" >
    <el-form :model="addForm" label-width="auto" >
      <el-form-item label="密钥算法">
        <el-select v-model="addForm.algorithm" placeholder="请选择算法类型">
          <el-option label="明文不加密" value="simple" />
          <el-option label="对称加密算法" value="AES" />
          <el-option label="非对称加密算法" value="RSA" disabled />
        </el-select>
      </el-form-item>
      <el-form-item label="标题">
        <el-input v-model="addForm.title" />
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="addForm.remark" type="textarea"/>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogVisible =false">取消</el-button>
        <el-button type="primary" @click="clickSubBtn">提交</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<style scoped lang="scss">

</style>
